home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI MineSet 2.5
/
SGI MineSet 2.5.iso
/
dist
/
imgtools.idb
/
usr
/
share
/
src
/
imgtcl
/
imgblend.z
/
imgblend
Wrap
Text File
|
1998-05-12
|
4KB
|
121 lines
#!/usr/sbin/imgtcl
if { $argc != 1 } {
echo "Usage: $argv0 filename"
exit
}
# procedure to create the sliders that adjust the rotate/zoom/blend values
# it takes the name of its parent widget and returns the name of the toolbar
proc initToolBar { parent } {
global viewWid
set bar $parent.Bar
# create a vertical rowColumn and put it on the right side of the form
xmRowColumn $bar managed -orientation VERTICAL \
-bottomAttachment ATTACH_FORM \
-rightAttachment ATTACH_FORM \
-topAttachment ATTACH_FORM
# create a slider for the zoom value
xmLabel $bar.zoomLab managed -labelString "Zoom"
xmLabel $bar.zoomVal managed -labelString "1.0"
xmScale $bar.zoom managed -orientation VERTICAL \
-minimum -100 -maximum 100 -value 0
$bar.zoom dragCallback { Update DoZoom %value }
$bar.zoom valueChangedCallback { Update DoZoom %value }
DoZoom 0
# create slider for the rotation angle
xmLabel $bar.rotateLab managed -labelString "Rotate"
xmLabel $bar.rotateVal managed -labelString "0"
xmScale $bar.rotate managed -orientation VERTICAL \
-minimum 0 -maximum 360 -value 0
$bar.rotate dragCallback { Update DoRotate %value }
$bar.rotate valueChangedCallback { Update DoRotate %value }
DoRotate 0
# create a slider for the blend value
xmLabel $bar.blendLab managed -labelString "Blend"
xmLabel $bar.blendVal managed -labelString "0.3"
xmScale $bar.blend managed -orientation VERTICAL \
-minimum 0 -maximum 100 -value 30
$bar.blend dragCallback { Update DoBlend %value }
$bar.blend valueChangedCallback { Update DoBlend %value }
DoBlend 30
return $bar
}
# set the zoom factor on the rotZoomImg and update the label
proc DoZoom { factor } {
set factor [expr pow(2, $factor/100.)]
rzimg setZoom $factor $factor
set factor [string range $factor 0 3]
.main.work.Bar.zoomVal setValues -labelString $factor
}
# set the rotate angle on the rotZoomImg and update the label
proc DoRotate { angle } {
rzimg setAngle $angle
set angle [string range $angle 0 3]
.main.work.Bar.rotateVal setValues -labelString $angle
}
# set the blend value on the blendImg and update the label
proc DoBlend { alpha } {
set alpha [expr $alpha / 100.]
blendimg setConstAlpha $alpha
set alpha [string range $alpha 0 3]
.main.work.Bar.blendVal setValues -labelString $alpha
}
# Update performs one of the above operations and forces the viewer to paint
proc Update { op value } {
global viewWid
$op $value
[$viewWid getViewer] paint
}
# AddFile opens the image file and creates a chain:
# file -> rotzoom -> blend
# then blend is then added to the viewer
proc AddFile { filename } {
global viewWid
ilFileImgOpen fileimg $filename
ilRotZoomImg rzimg fileimg 0 1 1 ilBiLinear
rzimg setSize [fileimg getSizePtr]
ilBlendImgConst blendimg [ilInvertImg invimg rzimg] fileimg 0.5
set view [$viewWid addImage blendimg]
$viewWid setSelected 1 $view
}
# this call must precede any widget creation
xtAppInitialize
# create the main window and an xmForm as the work area
xmMainWindow .main managed
set work .main.work
xmForm $work managed
# make a viewer
set viewWid [vkviewer $work.viewer managed]
# Create an image processing chain and put the result into the viewer
AddFile $argv
# create the toolbar and attach it to the viewer's right side
set bar [initToolBar .main.work]
$work.viewer setValues \
-topAttachment ATTACH_FORM \
-leftAttachment ATTACH_FORM \
-bottomAttachment ATTACH_FORM \
-rightAttachment ATTACH_WIDGET -rightWidget $bar
# make the form the work area of the main window
.main setValues -workWindow $work
# realize everything and enter the X event loop
. realizeWidget
. mainLoop